


import React,{Suspense,lazy} from 'react'

import { HashRouter as Hash ,useRoutes,Navigate} from 'react-router-dom'
import Logins from './views/logins/router'
import Err from "./views/err/router"
import Home from "./views/homepage/router"
import 'antd/dist/antd.css'  
import Loading from './components/loading';
import { inject,observer} from 'mobx-react';
import { Store } from './mobx/store';


const MainIndex =  () => {
  return (
    <div className='main'>
      <Hash>
        <Suspense fallback={Loading("loading...")}> 
          <RouterIndex/>
        </Suspense>
      </Hash>
    </div>
  )
}

const RouterIndex = ()=>{
  interface Router{   //ts自定义类型
    path:string,
    element:any,
  }
  const elements = useRoutes([  //路由配置
    {
      path:"/",
      element:<Navigate  replace to="/login" /> 
      //Navigate路由自带组件
    },
    ...Logins,
    ...Err,
    ...Home,
    {
      path:"*",
      element:<Navigate replace to={"/404"}/>
    }
  ])
  return elements
}

export default MainIndex